<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>我的牌位</title>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no, email=no" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script type="text/javascript" src="{MODULE_URL}public/fo/js/flexible.js"></script>
    <script type="text/javascript" src="{MODULE_URL}public/fo/js/pageLoading.js"></script>
    <script type="text/javascript" src="{MODULE_URL}public/fo/js/jquery.js"></script>
    <link type="text/css" rel="stylesheet" href="{MODULE_URL}public/fo/css/index.css">
    <link type="text/css" rel="stylesheet" href="{MODULE_URL}public/fo/css/diligence_list.css">
    <link type="text/css" rel="stylesheet" href="{MODULE_URL}public/fo/css/record.css">
    <link type="text/css" rel="stylesheet" href="{MODULE_URL}public/fo/css/tablet.css">
    <link type="text/css" rel="stylesheet" href="{MODULE_URL}public/fo/css/tribute.css">
    <link type="text/css" rel="stylesheet" href="{MODULE_URL}public/fo/css/back.css">
</head>
<body>

<script src="{MODULE_URL}public/fo/js/zepto.min.js"></script>


<div class="tablet">
    <ul class="tablet_list clearfix">


    </ul>
</div>
<div class="tipMask" id="tipMask"></div>
<div class="noticetip" id="noticetip">
    <div class="cont">

    </div>
    <div class="commonbtn">
        <a href="javascript:;" class="cnbtn">确定</a>
    </div>
</div>

<script>
    $(function(){

        $('ul.tablet_list>li.off').on('tap', function(){
            $('#noticetip, #tipMask').css('display', 'block');
        });

        $('a.cnbtn').on('tap', function(){
            $(this).parent().parent().css('display', 'none');
            $(this).parent().parent().prev().css('display', 'none');
        });

        $('ul.tablet_list>li.on').on('tap', function(){
            if (!$(this).hasClass('done')) {
                $(this).find('.choosetip, .tipMask').css('display', 'block');
            }
        });

        $('.choosetip, .chooseEnter').on('tap', function(e){
            e.stopPropagation();
        });

        $('.tabtype>.name').on('tap', function(){
            var txt = $(this).text(),
                    pt = $(this).parents('.choosetip');
            pt.css('display', 'none');
            pt.next().css('display', 'block').find('.name').text(txt);
        });

        $('a.back').on('click', function(){
            var pt = $(this).parents('.chooseEnter');
            pt.css('display', 'none');
            pt.prev().css('display', 'block');
        });

        $('a.sure').on('click', function(){
            var pt = $(this).parents('.enterbtn').siblings('.cont').find('.tabenter'),
                    val1 = pt.find('.name1').val().substring(0, 6),
                    val2 = pt.find('.name2').val().substring(0, 6);
            valid = pt.find('.did').val();
            if (val1=='' && val2=='') {
                alert('您还没输名字');
            }else{
                $(this).parents('.on').addClass('done');
                $(this).parents('.chooseEnter').css('display', 'none');
                $(this).parents('.chooseEnter').siblings('.tipMask').css('display', 'none');
                var pt2 = $(this).parents('.enterbtn').siblings('.cont').find('.tabtype'),
                        pt3 = $(this).parents('.chooseEnter').siblings('.tabname'),
                        pt4 = $(this).parents('.chooseEnter').siblings('.time'),
                        type = pt2.find('.name').text(),
                        oLi = $(this).parents('li'),
                        src_qf = oLi.find('img').attr('data-qf'),
                        src_cd = oLi.find('img').attr('data-cd');
                //		alert("val1"+val1+"val2"+val2+"id==="+valid+"---type==="+type);
                $.ajax({
                    type:"POST",
                    url:"/index.php?g=Wap&m=Guanyi&a=saveTablet",
                    dataType:"json",
                    data:{
                        pwid:valid,
                        name1:val1,
                        name2:val2,
                        type:type
                    },
                    success:function(data){
                        if(data.error == 3){
                            alert("this is error 3");
                        }else if(data.error == 2){
                            alert("this is error 2");
                        }else if(data.error == 1){
                            //				alert("添加成功");
                        }
                    }
                });
                //			coutDown();
                //			pt4.text('剩余时间：'+day+'天'+h+'时');
                pt3.find('span').eq(0).text(val1);
                pt3.find('span').eq(1).text(val2);
                if (type=='超度牌位') {
                    oLi.find('img').attr('src', src_cd);
                }else {
                    pt3.addClass('c2');
                    oLi.find('img').attr('src', src_qf);
                }
            }
        });

    });

    var day,h;
    function coutDown(){
        var now = new Date(),
                hour = now.getHours(),
                totalH = 10*24, //自定义常量，倒计时10天
                surplusH = totalH - hour;

        day = Math.floor(surplusH/24), //剩余天
                h = surplusH%24;

        setTimeout(coutDown, 3600000);
    }
</script>


<!-- 底部导航 -->
 {template 'baifocommon/nav'}
<!-- 底部导航 -->

<div id="mask"></div>

<script src="{MODULE_URL}public/fo/js/fun.js"></script>


</body>
</html>